{include app:admin.inc.header}
<!--tmpl-resource-->
{include app:admin.inc.top}


<div class="container-fluid content-body">
	<div class="main">
		<!-- left side start-->
		{include admin.inc.menu}
		<!-- left side end-->


		<!-- main content start-->
		<section class="right-section" id="right-section">
			<!-- start of inner-frame -->
			<div class="inner-iframe">

				<!-- page breadcrumb start-->
				{include admin.inc.bread}
				<!-- page "breadcrumb end-->
				<!-- Nav tabs -->
				<ul class="nav nav-tabs">

					<li {if $id==''}class="active"{/if}><a {if $id==''}href="javascript:void(0);"{else}href="{$add_url}"{/if}><i class="glyphicon glyphicon-plus"></i>添加特约品牌</a></li>
					<li><a href="{$index_url}" ><i class="glyphicon glyphicon-th-list"></i>特约品牌列表</a></li>
					{if $id != ''}<li class="active"><a href="javascript:void(0);"><i class="glyphicon glyphicon-edit"></i> 编辑特约品牌</a></li>{/if}
				</ul>
				<div class="inner-container">
					<form role="form" class="content-add-form form-horizontal" id="content-add-form" autocomplete="off">
						<!--tmpl-fields-->
						<!-- input -->
						<div class="form-group">
							<label class="col-sm-2 control-label">
								<span class="asterisk">*</span>
								标题 
							</label>
							<div class="col-sm-6">
							<input  dtype="" class="form-control" maxlength="50" name="data[title]" placeholder="标题" required cname="标题" value="{$item[title]}" />
							</div>
						</div>
						<p class="help-block"></p>

						<div class="form-group">
							<label class="col-sm-2 control-label">货品类型</label>
							<div class="col-sm-4">
								<select name="data[cate]" class="form-control select2">
									{loop $cates $cate}
									<option {if $cate[type_name]==$item[cate]}selected{/if}  value="{$cate.type_name}">{$cate.type_name}</option>
									{/loop}
								</select>
							</div>
						</div>
						<p class="help-block"></p>

						<!-- input -->
						<div class="form-group">
							<label class="col-sm-2 control-label">
								<span class="asterisk">*</span>
								网址 
							</label>
							<div class="col-sm-6">
							<input  dtype="url" class="form-control" maxlength="255" name="data[url]" placeholder="网址" required cname="网址" value="{$item[url]}" />
							</div>
						</div>
						<p class="help-block"></p>
						
						<!-- image -->
						<div class="form-group">
							<label class="col-sm-2 control-label">LOGO</label>
							<div class="clearfix col-sm-4">
								<div id="image-box" class="pull-left">
									<!--tmpl-uploadedimage-->
									<input type="hidden" name="data[logo]" value="{$item[logo]}" />
								</div>
								<div class="pull-left">
									<span name="src" class="img-upload text-center" id="image-btn-logo">
										<i class="glyphicon glyphicon-picture"></i>
										<span class="upload-text"><i class="glyphicon glyphicon-plus"></i> 添加图片</span>
									</span>
								</div>
							</div>
							<div class="col-sm-4">
								* 图片比率为1:1 *
								<br>
								* 推荐大小为180 x 180 (px)
							</div>
						</div>
						<!-- input -->
						<div class="form-group">
							<label class="col-sm-2 control-label">
								<span class="asterisk">*</span>
								排序 
							</label>
							<div class="col-sm-4">
								<input  dtype="number" class="form-control" maxlength="{maxlength}" name="data[listorder]" placeholder="排序" required cname="排序" value="{if $item[listorder]}{$item[listorder]}{else}50{/if}" />
							</div>
							<div class="col-sm-4">
								*排序由小到大排序，数字越小，排得越前*
							</div>
						</div>
						<p class="help-block"></p>
						
						<!-- switch -->
						<div class="form-group">
							<label class="col-sm-2 col-sm-2 control-label">状态</label>
							<div class="col-sm-4">
								<input type="checkbox" id="switch-status" name="data[status]" class="bswitch" data-size="normal" {if $item[status]}checked{/if} data-on-text="启用" data-off-text="禁用">
							</div>
						</div>

						<!--tmpl-assocfields-->
						<div class="btn-group btn-group-or">
							<a href="{if $id==''}{$do_add_url}{else}{$do_edit_url}?id={$id}{/if}" class="btn btn-primary ajaxproxy"
								proxy='{"method":"post", "location":"{$index_url}"}'>提交保存</a>

						</div>
					</form><!-- content add form -->
				</div>
			</div><!-- end of inner -->
		</section>
	</div>
</div>
{include admin.inc.footer}

<!--tmpl-script-->

<!-- pagescript -->
<script type="text/javascript">
	seajs.use("admin/brand_add",function (parameter){
		
		/**--tmpl-templatejavascript--**/
		
		<!--tmpl-templatejavascript-->
		parameter.upload_url="{$upload_url}";
		parameter.image_search_url="{$image_search_url}";
		parameter.image_list_url="{$image_list_url}";
		
		parameter.init();		
		parameter.upload({
			{if $item[logo]}datas : ['{$item[logo]}'],{/if}
			onSuccess : function(data){
				$('input[name="data[logo]"]').val(data);
			},
			onRemove : function (data){
				console.log(data);
				$.post('{url /admin/upload/delete}',{file : data,table : 'brand',field : 'logo' ,id : '{$item[id]}'},function (data){},'json');
			}
		});
	});
</script>

</body>
</html>
